import pika

# 连接到 RabbitMQ 服务器
credentials = pika.PlainCredentials('admin', 'Parav1ew!')  # 替换为你的用户名和密码
parameters = pika.ConnectionParameters('10.10.2.236', 31331, '/', credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()

# 声明队列
queue_name = 'DRS00002'
channel.queue_declare(queue=queue_name, durable=True)  # durable=True 表示队列是持久化的

# 发送消息
message = 'Hello, World!'
channel.basic_publish(exchange='DRD_EXCHANGE01',
                      routing_key='',
                      body=message,
                      properties=pika.BasicProperties(
                          delivery_mode=2,  # 使消息持久化
                      ))

print(f" [x] Sent '{message}'")

# 关闭连接
connection.close()